package com.itheima.service.Impl;

import com.itheima.common.SubjectResult;
import com.itheima.mapper.HmSubjectsMapper;
import com.itheima.pojo.hm.HmSubjects;
import com.itheima.service.HmSubjectsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class HmSubjectsServiceImpl implements HmSubjectsService {
    @Autowired
    private HmSubjectsMapper subjectsMapper;
    @Override
    public List<SubjectResult> SimpleList() {
        List<HmSubjects> hmSubjects = subjectsMapper.selectList(null);
        List<SubjectResult> resultList = new ArrayList<>();
        for (HmSubjects hmSubject : hmSubjects) {
            SubjectResult subjectResult = new SubjectResult();
            subjectResult.setValue(hmSubject.getId());
            subjectResult.setLabel(hmSubject.getSubjectName());
            resultList.add(subjectResult);
        }
        return resultList;
    }
}
